﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Core.DataAccess.Model.Migrations.ProjectEntrepot
{
    public partial class addproducttype_top : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "entrepot_log",
                columns: table => new
                {
                    id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    order_key = table.Column<int>(nullable: false),
                    template_key = table.Column<int>(nullable: false),
                    purchase_key = table.Column<int>(nullable: false),
                    supplier_key = table.Column<int>(nullable: false),
                    count_stock = table.Column<decimal>(type: "decimal(18, 3)", nullable: false),
                    phone = table.Column<string>(unicode: false, maxLength: 11, nullable: false),
                    project_token = table.Column<string>(unicode: false, maxLength: 21, nullable: false),
                    content = table.Column<string>(unicode: false, nullable: true),
                    reg_time = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_entrepot_log", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "product_params",
                columns: table => new
                {
                    id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    title = table.Column<string>(unicode: false, maxLength: 30, nullable: false),
                    user_key = table.Column<long>(nullable: true, defaultValueSql: "((0))"),
                    phone = table.Column<string>(unicode: false, maxLength: 11, nullable: false),
                    project_token = table.Column<string>(unicode: false, maxLength: 21, nullable: false),
                    update_last_time = table.Column<DateTime>(type: "datetime", nullable: true),
                    reg_time = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_product_params", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "product_params_dic",
                columns: table => new
                {
                    id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    title = table.Column<string>(unicode: false, maxLength: 30, nullable: false),
                    params_key = table.Column<int>(nullable: false),
                    user_key = table.Column<long>(nullable: true, defaultValueSql: "((0))"),
                    phone = table.Column<string>(unicode: false, maxLength: 11, nullable: false),
                    project_token = table.Column<string>(unicode: false, maxLength: 21, nullable: false),
                    update_last_time = table.Column<DateTime>(type: "datetime", nullable: true),
                    reg_time = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_product_params_dic", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "product_purchase",
                columns: table => new
                {
                    id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    order_key = table.Column<int>(nullable: false),
                    template_key = table.Column<int>(nullable: false),
                    supplier_key = table.Column<int>(nullable: false),
                    sku_key = table.Column<int>(nullable: false),
                    purchase_key = table.Column<int>(nullable: false),
                    content = table.Column<string>(unicode: false, nullable: true),
                    count_stock = table.Column<decimal>(type: "decimal(18, 3)", nullable: false),
                    reg_time = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_product_purchase", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "product_sell",
                columns: table => new
                {
                    id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    order_key = table.Column<int>(nullable: false),
                    template_key = table.Column<int>(nullable: false),
                    sku_key = table.Column<int>(nullable: false),
                    supplier_key = table.Column<int>(nullable: false),
                    content = table.Column<string>(unicode: false, nullable: true),
                    count_stock = table.Column<decimal>(type: "decimal(18, 3)", nullable: false),
                    reg_time = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_product_sell", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "product_sku",
                columns: table => new
                {
                    id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    template_key = table.Column<int>(nullable: false),
                    supplier_key = table.Column<int>(nullable: false),
                    up_supplier_key = table.Column<int>(nullable: false),
                    sales_price = table.Column<decimal>(type: "decimal(18, 5)", nullable: true, defaultValueSql: "((0))"),
                    cost_price = table.Column<decimal>(type: "decimal(18, 5)", nullable: true, defaultValueSql: "((0))"),
                    count_stock = table.Column<decimal>(type: "decimal(18, 3)", nullable: false),
                    sales_confirm = table.Column<bool>(nullable: true, defaultValueSql: "((0))"),
                    content = table.Column<string>(unicode: false, nullable: true),
                    update_last_time = table.Column<DateTime>(type: "datetime", nullable: true),
                    reg_time = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_product_sku", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "product_template",
                columns: table => new
                {
                    id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    title = table.Column<string>(unicode: false, maxLength: 30, nullable: false),
                    type_key = table.Column<int>(nullable: false),
                    phone = table.Column<string>(unicode: false, maxLength: 11, nullable: false),
                    project_token = table.Column<string>(unicode: false, maxLength: 21, nullable: false),
                    supplier_key = table.Column<int>(nullable: false),
                    content = table.Column<string>(unicode: false, nullable: true),
                    confirm = table.Column<bool>(nullable: true, defaultValueSql: "((0))"),
                    update_last_time = table.Column<DateTime>(type: "datetime", nullable: true),
                    reg_time = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_product_template", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "product_type",
                columns: table => new
                {
                    id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    title = table.Column<string>(unicode: false, maxLength: 15, nullable: false),
                    user_key = table.Column<long>(nullable: true, defaultValueSql: "((0))"),
                    phone = table.Column<string>(unicode: false, maxLength: 11, nullable: false),
                    project_token = table.Column<string>(unicode: false, maxLength: 21, nullable: false),
                    up_key = table.Column<int>(nullable: true, defaultValueSql: "((0))"),
                    Top = table.Column<int>(nullable: true),
                    update_last_time = table.Column<DateTime>(type: "datetime", nullable: true),
                    reg_time = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_product_type", x => x.id);
                });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "entrepot_log");

            migrationBuilder.DropTable(
                name: "product_params");

            migrationBuilder.DropTable(
                name: "product_params_dic");

            migrationBuilder.DropTable(
                name: "product_purchase");

            migrationBuilder.DropTable(
                name: "product_sell");

            migrationBuilder.DropTable(
                name: "product_sku");

            migrationBuilder.DropTable(
                name: "product_template");

            migrationBuilder.DropTable(
                name: "product_type");
        }
    }
}
